<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <title></title>
    <% include("../inc/input_css.html"){}%>
    <style>
        label{
            width: 140px!important;
        }
    </style>

    <%
    var isAdd = false;
    var isEdit = false;

    if(isEmpty(resource.id)){
    isAdd = true;
    }else{
    isEdit = true;
    }%>
</head>
<body>
<div class="ibox">
    <div class="ibox-title">
        <div class="pull-left mbx navbar_title">
            <span class="current">权限管理</span>
            <span class="line">/</span>
            <span class="current"><a href="/shop/productCategroy/list">资源管理</a></span><span class="line">/</span>
            <%if(isAdd){%>添加资源<%}else{%>编辑资源<%}%>
        </div>
    </div>
    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="padding-40">
                    <form  action="<%if (isAdd){%>${base}/shop/resource/save<%}else{%>${base}/shop/resource/update<%}%>" method="post" class="form-horizontal form-validate">
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>分类名称</label>
                                <div class="col-sm-3">
                                    <input type="text" name="resource.name" id="resourceName" value="${resource.name!}" class="form-control light-input" required="true">
                                    <input type="hidden" name="resource.id" value="${resource.id!}" />
                                    <input type="hidden" name="resource.path" value="${resource.path!}" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">上级分类</label>
                                <div class="col-sm-3">
                                    <%if(isAdd){%>

                                    <select name="resource.parent_id" class="form-control light-input" style="height: 31px">
                                        <option value="">顶级分类</option>
                                        <%for(list in resourceTreeList){%>
                                        <option value="${list.id}">
                                            <%if (list.level != 0){%>
                                            <%for( i in range(0,list.level!0)){%>------<%}%>
                                            <%}%>
                                            ${list.name}
                                        </option>
                                        <%}%>
                                    </select>
                                    <%}else{%>
                                    ${resource.parent.name!'顶级分类'}
                                    <%}%>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>排序</label>
                                <div class="col-sm-3">
                                    <input type="text" placeholder="请输入0-999正整数" name="resource.orderList"  value="${resource.orderList!50}" class="form-control light-input" maxlength="10" required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">url</label>
                                <div class="col-sm-3">
                                    <input type="text"  name="resource.url"  value="${resource.url!}" class="form-control light-input" maxlength="10">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">icon</label>
                                <div class="col-sm-3">
                                    <input type="text"  name="resource.icon"  value="${resource.icon!}" class="form-control light-input" maxlength="10">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">备注</label>
                                <div class="col-sm-3">
                                    <textarea name="resource.description"  rows="7" style="" class="form-control light-input">${resource.description!}</textarea>
                                </div>
                            </div>


                            <div class="form-group" style="margin-top: 24px">
                                <label class="col-sm-2 control-label "></label>
                                <div class="col-sm-4 col-sm-offset-0">
                                    <button class="hive-btn-cancle" id="btn_cancle" type="button" onclick="history.back()">&nbsp;取消&nbsp;</button>
                                    <button class="hive-btn hive-btn-primary margin-left-8" type="submit">&nbsp;提交&nbsp;
                                    </button>
                                </div>
                            </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
<% include("../inc/input_js.html"){}%>
<script type="text/javascript">
    function check(){
        var resourceName=$("#resourceName").val();
        var resourceOrderList=$("#resourceOrderList").val();
        var listReg=/^\d*\d*\d+$/;
        if(!resourceName){
            layer.msg("请输入分类名称!");
            return false;
        }
        if(!listReg.test(resourceOrderList) || parseInt(resourceOrderList)>999){
            layer.msg("排序请输入0-999的正整数!");
            return false;
        }
    }
</script>
</html>